package practice.P01M03;

import org.junit.jupiter.api.Test;

import java.text.SimpleDateFormat;
import java.time.*;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

public class Play {
    @Test
    public void getCurrentTime() {
        final long l = System.currentTimeMillis();
        System.out.println(l);
    }

    @Test
    public void newDate() {
        Date d = new Date();
        System.out.println(d);
        final long l = System.currentTimeMillis();
        Date d1 = new Date(l);
        System.out.println(d1);
    }

    @Test
    public void simpleDateFormat() {
        final long l = System.currentTimeMillis();
        Date d1 = new Date(l);
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("y/MM/dd HH:mm:ss.S");
        System.out.println(simpleDateFormat.format(d1));
    }

    @Test
    public void gregorianCalendar() {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("y/MM/dd HH:mm:ss.S");
        Calendar calendar = Calendar.getInstance();
        calendar.set(2021, Calendar.JULY, 29, 22, 9);
        calendar.set(Calendar.YEAR, 2019);
        calendar.set(Calendar.MONTH, Calendar.DECEMBER);
        calendar.set(Calendar.HOUR, 8);
        calendar.add(Calendar.HOUR, 2);
        Date d = calendar.getTime();
        System.out.println(simpleDateFormat.format(d));
    }

    @Test
    public void java8Date() {
        final LocalDate now = LocalDate.now();
        System.out.println(now);
        final LocalDateTime now1 = LocalDateTime.now();
        System.out.println(now1);
        System.out.println(LocalDateTime.of(2021, 7, 29, 10, 53));
    }

    @Test
    public void instant() {
        final OffsetDateTime offsetDateTime = Instant.now().atOffset(ZoneOffset.ofHours(8));
        System.out.println(offsetDateTime);
    }
}
